package designparttendemo.simpleFactory;


import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.lang.reflect.InvocationTargetException;

@Component
public class SimpleFactory {
    public SimpleFactory(){}

    @Bean("bus")
    public ICar createBus() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        return Bus.class.getConstructor(null).newInstance();
    }

    @Bean("truck")
    public ICar createTruck() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        return Truck.class.getConstructor(null).newInstance();
    }
}
